package com.itheima.d5_recursion;

/**
 * 目标：掌握递归的应用，执行流程和算法思想。
 */
public class RecursionTest2 {
    public static void main(String[] args) {
        System.out.println(sum(100));
        System.out.println(cheng(20));
    }

    public static long sum(int n) {
        if (n == 1) {
            return 1;
        }
        return sum(n - 1) + n;
    }
public static long cheng(int n ){
    if (n == 1) {
        return 1 ;
    }
    return cheng(n-1)*n;
}
}
